package com.yunji.news.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunji.news.entity.Major;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 专业信息Mapper接口
 *
 * @author yunji
 * @since 2024-11-25
 */
@Mapper
public interface MajorMapper extends BaseMapper<Major> {

    /**
     * 根据院校ID查询专业列表
     *
     * @param schoolId 院校ID
     * @return 专业列表
     */
    @Select("SELECT * FROM majors WHERE school_id = #{schoolId} AND status = 1 AND deleted = 0 ORDER BY name")
    List<Major> selectBySchoolId(@Param("schoolId") Long schoolId);

    /**
     * 查询专业分类列表
     *
     * @return 专业分类列表
     */
    @Select("SELECT DISTINCT category FROM majors WHERE status = 1 AND deleted = 0 AND category IS NOT NULL ORDER BY category")
    List<String> selectCategories();
}